<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 第1步,引入vue文件,去https://cdn.bytedance.com/找 -->
  <script src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript">
  </script>
</head>

<body>
  <!-- 第2步创建根组件元素 -->
  <div id="app">
    <!--  在组件上面v-on,是父子通信,监听消息,监听子组件发过来消息,巧合消息名称为click -->
    <my-button @click="onClick"></my-button>
  </div>
</body>
<script>
  Vue.component('my-button', {
    template: `
    <div><button @click="$emit('click')">按钮</button></div>
    `
  })

  //第3步,创建vue的实例
  new Vue({
    el: '#app',
    data() {
      return {
        msg: 'hello vue'
      }
    },
    methods: {
      onClick() {
        console.log('点击了');
      }
    }
  })

</script>

</html>
